package us.versus.them.kitkattoe;

import flash.display.Graphics;
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.geom.Point;
import flash.media.Sound;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;

// this bit of bizarreness is to get the Ends enum!
import us.versus.them.kitkattoe.App;

class GameOver extends Base {
	var app:App;
	var timer:Timer;

	public function new( app, end:Ends ) {
		super();
		this.app = app;
		var splash = 'tide';
		switch( end ) {
			case me: splash = 'cat.win'; 
			case yu: splash = 'u.win'; 
			default: splash = 'tide';
		}
		add( Base.displayObjectForName( splash ) );

		this.timer = new Timer( 1000 * 2, 1 );
		this.timer.addEventListener( TimerEvent.TIMER , nu );
		this.timer.start();
		this.addEventListener( MouseEvent.MOUSE_DOWN, mouse_down );
	}

	public function add( x:DisplayObject ) {
		addChild( x );
	}

	public override function mouse_down( mouseEvent : MouseEvent ) {
		this.nu();
	}

	public function nu( ?d:Dynamic ) {
		this.timer.stop();
		this.app.nuGame();
		removeEventListeners();
	}
}
